{% load i18n %}
{% load promgen %}
<tr>
  <td class="col-xs-3" v-pre>
    <a href="{% url 'group-detail' group.id %}">
    {{ group.name }}
    </a>
  </td>
  <td class="col-xs-3" style="word-break: break-all" v-pre>
    {% for perm in perms %}
    <span
      class="label {% if perm == 'Admin' %} label-danger {% elif perm == 'Editor' %} label-info {% else %} label-success {% endif %}"
    >
      {{ perm|upper }}
    </span>
    {% endfor %}

    <button
      style="background: none"
      class="btn btn-xs"
      data-toggle="collapse"
      data-target="#group{{group.id}}"
    >
      <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
    </button>
    <div class="collapse" id="group{{group.id}}">
      <form
        method="post"
        action="{% url 'permission-assign' %}"
        style="display: inline"
      >
        {% csrf_token %}
        <input
          name="next"
          type="hidden"
          value="{{ request.get_full_path }}#members"
        />
        <input name="model" type="hidden" value="{{ object | klass }}" />
        <input name="id" type="hidden" value="{{ object.id }}" />
        <input name="group" type="hidden" value="{{ group.name }}" />
        <input name="perm-type" type="hidden" value="group" />
        {{ permission_form.permission }}
        <button class="btn btn-primary btn-xs">Change</button>
      </form>
    </div>
  </td>
  <td class="col-xs-3" v-pre>
    <form
      method="post"
      action="{% url 'permission-delete' %}"
      onsubmit="return confirm('{% trans 'Delete all permissions for group?' %}')"
      style="display: inline"
    >
      {% csrf_token %}
      <input type="hidden" name="group" value="{{ group.name }}" />
      <input
        name="next"
        type="hidden"
        value="{{ request.get_full_path }}#members"
      />
      <input name="model" type="hidden" value="{{ object | klass }}" />
      <input name="id" type="hidden" value="{{ object.id }}" />
      <input name="perm-type" type="hidden" value="group" />
      <button type="submit" class="btn btn-danger btn-xs">Delete</button>
      {% if object|klass == "Service" %}
      <div class="form-check">
        <input
          type="checkbox"
          class="form-check-input"
          id="removeSubPermissions"
          name="remove_sub_permissions"
          checked
        />
        <label
          class="form-check-label"
          for="removeSubPermissions"
          style="display: inline"
        >
          <small>{% trans "Remove permissions in child projects" %}</small>
        </label>
      </div>
      {% endif %}
    </form>
  </td>
</tr>
